namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0069 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.SysTask",
                c => new
                    {
                        TaskId = c.Int(nullable: false, identity: true),
                        RecordStatus = c.String(),
                        CreatedBy = c.Int(),
                        CreatedWhen = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                        ApprovedBy = c.Int(),
                        ApprovedWhen = c.DateTime(),
                        RejectedBy = c.Int(),
                        RejectedWhen = c.DateTime(),
                        CanceledBy = c.Int(),
                        CanceledWhen = c.DateTime(),
                        CurrentTaskHistoryId = c.Int(),
                    })
                .PrimaryKey(t => t.TaskId)
                .ForeignKey("dbo.SysTaskHistory", t => t.CurrentTaskHistoryId)
                .Index(t => t.CurrentTaskHistoryId);
            
            CreateTable(
                "dbo.SysTaskHistory",
                c => new
                    {
                        TaskHistoryId = c.Int(nullable: false, identity: true),
                        CurrentApproverType = c.Int(nullable: false),
                        CurrentApproverEmpIds = c.String(),
                        IsApproveAble = c.Boolean(nullable: false),
                        IsForwardable = c.Boolean(nullable: false),
                        IsRejectable = c.Boolean(nullable: false),
                        IsPendable = c.Boolean(nullable: false),
                        IsSendBackable = c.Boolean(nullable: false),
                        CurrentStepNo = c.Int(),
                        NextStepNo = c.Int(),
                        RecordStatus = c.String(),
                        CreatedBy = c.Int(),
                        CreatedWhen = c.DateTime(),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                        TaskId = c.Int(),
                        FromTaskId = c.Int(),
                        ToTaskId = c.Int(),
                        Task_TaskId = c.Int(),
                    })
                .PrimaryKey(t => t.TaskHistoryId)
                .ForeignKey("dbo.SysTask", t => t.TaskId)
                .ForeignKey("dbo.SysTask", t => t.FromTaskId)
                .ForeignKey("dbo.SysTask", t => t.ToTaskId)
                .ForeignKey("dbo.SysTask", t => t.Task_TaskId)
                .Index(t => t.TaskId)
                .Index(t => t.FromTaskId)
                .Index(t => t.ToTaskId)
                .Index(t => t.Task_TaskId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.SysTaskHistory", new[] { "Task_TaskId" });
            DropIndex("dbo.SysTaskHistory", new[] { "ToTaskId" });
            DropIndex("dbo.SysTaskHistory", new[] { "FromTaskId" });
            DropIndex("dbo.SysTaskHistory", new[] { "TaskId" });
            DropIndex("dbo.SysTask", new[] { "CurrentTaskHistoryId" });
            DropForeignKey("dbo.SysTaskHistory", "Task_TaskId", "dbo.SysTask");
            DropForeignKey("dbo.SysTaskHistory", "ToTaskId", "dbo.SysTask");
            DropForeignKey("dbo.SysTaskHistory", "FromTaskId", "dbo.SysTask");
            DropForeignKey("dbo.SysTaskHistory", "TaskId", "dbo.SysTask");
            DropForeignKey("dbo.SysTask", "CurrentTaskHistoryId", "dbo.SysTaskHistory");
            DropTable("dbo.SysTaskHistory");
            DropTable("dbo.SysTask");
        }
    }
}
